<template>
  <!-- tableData  传入数据 -->
  <!-- 
  /*
 {"id":999,"name":"老王",
 "age":22,"email":"4441",
 "createtime":"2021-10-16T14:11:11.000+00:00",
 "updatetime":"2021-10-16T14:11:36.000+00:00",
 "deleted":false,"password":"123456",
 "answersum":100,
 "head":"hadno",
 "data":"1111",
 "classify":"fff"}
*/

 -->
  <div style="height: 500px;">
    <el-table :data="tableData.data" style="width: 100% ;overflow:auto;" class="infinite-list" v-infinite-scroll="load">
      <!-- v-infinite-scroll="load" 无限滚动   verflow:auto   滚动条 -->
      <el-table-column prop="id" label="id">
      </el-table-column>

      <el-table-column prop="age" label="年龄" width="180">
      </el-table-column>
      <el-table-column prop="email" label="email" width="180">
      </el-table-column>
      <el-table-column prop="createtime" label="创建时间" width="180">
      </el-table-column>

      <el-table-column label="操作">

        <template slot-scope="scope">
          <!--  slot-scope="scope"  为专门提供的插槽    -->
          <el-popconfirm confirm-button-text='删除' 
          cancel-button-text='算了' 
          @confirm="deledtById(scope.$index)"
          icon="el-icon-info" icon-color="red"
            title="这是一段内容确定删除吗？">
            <!-- confirm 确认触发事件 -->
            <el-button slot="reference" size="mini" type="primary" plain >删除？
            </el-button>
          </el-popconfirm>
          <!-- showIndex(scope.$index)   scope.$index  获取（数组）下标-->
          <!-- 插槽 数据 -->
        </template>
      </el-table-column>

      <!-- <el-table-column
      fixed="right"
      label="操作"
      width="120">
      <template slot-scope="scope">
        <el-button
          @click.native.prevent="deleteRow(scope.$index, tableData)"
          type="text"
          size="small">
          移除
        </el-button>
      </template>
    </el-table-column> -->


    </el-table>
  </div>
</template>
<script>
  // 1-1
  // 已提交的单订
  export default {
    name: "questionTable",
    data() {
      return {
        // 数据集合
        tableData: dt2,
        // 滚动信息统计
        count: 3
      }
    },
    methods: {
      deledtById(index) {
        // alert(this.tableData["data"][index]["id"])
        // 删除逻辑
        this.$axios.get(this.MYURL + "/answerer/deleteByid/" + index)
          // http://localhost:8001/miaosha/selectAll 
          .then(res => {
            // this.tableData=res
            this.$notify({
              title: '成功',
              message: '删除成功：' + index,
              type: 'success'
            });
            this.tableData = res
          }
          )
          .catch(
            (errorMsg) => {
              this.$notify.error({
                title: '失败  id:' + index,
                message: '删除失败:' + errorMsg,
              })
            })
      },
      // 滚动信息
      load() {
        this.count += 2
        console.log("滚动条count:", this.count)
      },

      //提问者信息，这里先用回答者顶替一下，后面记得改
      getQuestioners() {
        this.$axios.get(this.MYURL + "/answerer/selectAll")
          // http://localhost:8001/miaosha/selectAll 
          .then(res => {
            // this.tableData=res
            console.log("提交表：", res)
            this.tableData = res
          }
          )
          .catch(function (error) { alert("请求失败" + error) })
      },



    },
    mounted() {
      // 发送获取请求
      // this.getQuestioners()
      this.getQuestioners()
    },
  }

  // let dt = [{
  //   date: '2016-05-02',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1518 弄',
  //   id: 15
  // }, {
  //   date: '2016-05-04',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1517 弄'
  // }, {
  //   date: '2016-05-01',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1519 弄'
  // }, {
  //   date: '2016-05-03',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1516 弄'
  // }, {
  //   date: '2016-05-02',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1518 弄',
  //   id: 15
  // }, {
  //   date: '2016-05-04',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1517 弄'
  // }, {
  //   date: '2016-05-01',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1519 弄'
  // }, {
  //   date: '2016-05-03',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1516 弄'
  // }, {
  //   date: '2016-05-02',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1518 弄',
  //   id: 15
  // }, {
  //   date: '2016-05-04',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1517 弄'
  // }, {
  //   date: '2016-05-01',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1519 弄'
  // }, {
  //   date: '2016-05-03',
  //   name: '1111',
  //   address: '上海市普陀区金沙江路 1516 弄'
  // }, {
  //   date: '2016-05-02',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1518 弄',
  //   id: 15
  // }, {
  //   date: '2016-05-04',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1517 弄'
  // }, {
  //   date: '2016-05-01',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1519 弄'
  // }, {
  //   date: '2016-05-03',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1516 弄'
  // }, {
  //   date: '2016-05-02',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1518 弄',
  //   id: 15
  // }, {
  //   date: '2016-05-04',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1517 弄'
  // }, {
  //   date: '2016-05-01',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1519 弄'
  // }, {
  //   date: '2016-05-03',
  //   name: '王小虎',
  //   address: '上海市普陀区金沙江路 1516 弄'
  // }]

  let dt2 = [{ "id": 999, "name": "老王", "age": 22, "email": "4441", "createtime": "2021-10-16T14:11:11.000+00:00", "updatetime": "2021-10-16T14:11:36.000+00:00", "deleted": false, "password": "123456", "answersum": 100, "head": "hadno", "data": "1111", "classify": "fff" }, { "id": 14492645373043912, "name": "老八", "age": 23, "email": "123456789", "createtime": "2021-10-16T14:42:46.000+00:00", "updatetime": "2021-11-08T17:52:53.000+00:00", "deleted": false, "password": "2222222", "answersum": 3, "head": "hhh", "data": "ddd", "classify": "主播" }, { "id": 1449264537304391333, "name": "老八", "age": 23, "email": "123456789", "createtime": "2021-10-16T14:42:46.000+00:00", "updatetime": "2021-10-16T14:42:46.000+00:00", "deleted": false, "password": "2222222", "answersum": 3, "head": "hhh", "data": "ddd", "classify": "主播" }, { "id": 1449264537304391444, "name": "老八", "age": 23, "email": "123456789", "createtime": "2021-10-16T14:42:46.000+00:00", "updatetime": "2021-10-16T14:42:46.000+00:00", "deleted": false, "password": "2222222", "answersum": 3, "head": "hhh", "data": "ddd", "classify": "主播" }, { "id": 1449264537304391555, "name": "老八", "age": 23, "email": "123456789", "createtime": "2021-10-16T14:42:46.000+00:00", "updatetime": "2021-10-16T14:42:46.000+00:00", "deleted": false, "password": "2222222", "answersum": 3, "head": "hhh", "data": "ddd", "classify": "主播" }, { "id": 1449264537304391666, "name": "老八", "age": 23, "email": "123456789", "createtime": "2021-10-16T14:42:46.000+00:00", "updatetime": "2021-10-16T14:42:46.000+00:00", "deleted": false, "password": "2222222", "answersum": 3, "head": "hhh", "data": "ddd", "classify": "主播" }, { "id": 1449264537304391777, "name": "老k", "age": 23, "email": "123456789", "createtime": "2021-10-16T14:42:46.000+00:00", "updatetime": "2021-10-16T14:42:46.000+00:00", "deleted": false, "password": "2222222", "answersum": 3, "head": "hhh", "data": "ddd", "classify": "主播" }]
</script>
<style scoped>
</style>